"""
pip install openpyxl

"""

import openpyxl
# windows 下面的路径 r 防止转译
wb = openpyxl.load_workbook(r'E:\lemonpython\basic\test.xlsx')
print(wb)

# 0. active 表示被选择的sheet
active_sheet = wb.active

#  1.通过索引获取sheet
# wb.worksheet 获取所有表单
# wb.worksheets[0]   获取第一个sheet

# 2.通过sheet名
sheet2 = wb['register']
print(sheet2)

# 三、获取单元格内容 cell.value
cell = sheet2.cell(1,1)
print(cell.value)

# 获取某一行
print(sheet2[1])
# 值，循环获取
for column in sheet2[1]:
    print("行值",column.value)

# 某一列
print(sheet2['A'])

# 获取多行 切片，包头包尾
print(sheet2[1:3])

# 获取所有行
total_data = list(sheet2.rows)
# print(total_data,"********")